package com.yk._10四大函数接口;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class FunctionInterface {

    public static void main(String[] args) {
        //函数形接口
        Function<String, String> toUpcaseFunction = new Function<String, String>() {
            @Override
            public String apply(String o) {
                return o.toString().toUpperCase();
            }
        };
        //lamdba表达式简化写法
        Function toUpcaseFunction1 = (str)->{return str.toString().toUpperCase();};


        System.out.println(toUpcaseFunction.apply("common"));
        System.out.println(toUpcaseFunction1.apply("lamdba"));


        //断定型接口
        Predicate<String> predicate = (str)->{
            return str.isEmpty();
        };
        System.out.println(predicate.test("The Str Is Not Empty"));


        //共给形接口
        Supplier<Object> objectSupplier = () -> "Supplier Create";
        Object o = objectSupplier.get();
        System.out.println(o);

        //消费型接口
        Consumer consumer = (str) -> {
            System.err.println(str);
        };
        consumer.accept("Consumer Accept....");

    }

}
